package com.gcstorage.tvdev.view;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.gcstorage.tvdev.R;


/**
 * created by Sanpark on 2020-07-15 09:09
 */
public class LoadingDialog extends Dialog {
    private ImageView loadingImg;
    private Animation mRefreshAnim;

    public LoadingDialog(@NonNull Context context) {
        super(context);
    }

    public LoadingDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    protected LoadingDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_dialog_loading);
        getWindow().setBackgroundDrawableResource(android.R.color.transparent);//去掉白色背景
        loadingImg = findViewById(R.id.iv_loading_img);
        mRefreshAnim = AnimationUtils.loadAnimation(getContext(), R.anim.anim_loading_progress);
        LinearInterpolator lin = new LinearInterpolator();
        mRefreshAnim.setInterpolator(lin);
    }

    @Override
    public void onStart() {
        super.onStart();
        loadingImg.startAnimation(mRefreshAnim);
    }
}
